//产品选购标签配置
import { request } from '@umijs/max';
export async function queryAttributeList(options) {
    console.log(options,'-')
     const result = await request('/api/mjProductPurchase/queryByPage', {
        method: 'POST',
        data: options,
      });
      console.log(result,'-')
      return { data: result.data.records, success: true,total:result.data.total }
    }
    
    /** api */
  export async function updateAttribute(options) {
      console.log(options,'----option')
      return request<{
        data;
      }>('/api/mjProductPurchase/edit', {
        method: 'POST',
        data:(options || {}),
      });
    }
    
    // 查询产品详情
    export async function queryDetailByProductIDORType(options) {
      const res = await  request<{
          data;
        }>('/api/mjProductDetail/queryDetailByProductIDORType', {
          method: 'POST',
          data:options
        });
        return res
  }
  export async function updateByProductIDType(options) {
    const res = await  request<{
        data;
      }>('/api/mjProductDetail/updateByProductIDType', {
        method: 'POST',
        data:options
      });
      return res
  }
  export async function addAttribute(options) {
    options.productId = 1;
    return request<{
      data;
    }>('/api/mjProductPurchase/add', {
      method: 'POST',
      data:(options || {}),
    });
  }
  
  export async function removeAttribute(options) {
    
    return request<{
      data;
    }>('/api/mjProductPurchase/delete', {
      method: 'GET',
      params:(options || {}),
    });
  }

  // 产品选购列表
  export async function queryProductPurchaseList(options) {
    const res = await request('/api/mjProductPurchase_price/queryByPage', {
      method: 'POST',
      data: options,
    });
    return { 
      data:res.data.productPurchasePriceList,
      success: true,
      purchasePriceVoList: res.data.purchasePriceVoList
    }
    return res;
  }

  // 产品选购状态更新
  export async function updateProductPurchaseStatus(options) {
    return request('/api/mjProductPurchase_price/editPriceStatus', {
      method: 'POST',
      data: options,
    });
  }

  // 产品选购价格更新
  export async function updateProductEdit(options) {
    return request('/api/mjProductPurchase_price/edit', {
      method: 'POST',
      data: options,
    });
  }
  //同步产品数据状态
  export async function syncProductStatus(options) {
    return request('/api/mjProduct/purchase', {
      method: 'GET',
      data: options,
    });
  }